package io.github.talelin.latticy.controller.api;

import io.github.talelin.core.token.Tokens;
import io.github.talelin.latticy.dto.MobileLoginDTO;
import io.github.talelin.latticy.service.NewUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/user")
@Validated
public class TokenController
{
    @Autowired
    private NewUserService userService;

    /**
     * 登陆
     */
    @PostMapping("/login")
    public Tokens login(@RequestBody @Validated MobileLoginDTO dto)
    {
        return userService.createToken(dto);
    }
}
